#include <vector>
#include <gtest/gtest.h>
#include <gmock/gmock.h>

#include <iostream>

#define protected public
#define private public
#include "acl/ops/acl_dvpp.h"
#include "single_op/op_executor.h"
#include "single_op/dvpp/common/dvpp_def_internal.h"
#include "single_op/dvpp/common/dvpp_util.h"
#include "single_op/dvpp/mgr/dvpp_manager.h"
#include "single_op/dvpp/base/video_processor.h"
#include "single_op/dvpp/v200/video_processor_v200.h"
#include "single_op/dvpp/v200/image_processor_v200.h"
#include "single_op/dvpp/v100/video_processor_v100.h"
#include "single_op/dvpp/mgr/dvpp_manager.h"
#include "single_op/dvpp/common/callback_info_manager.h"
#undef private
#undef protected

#include "acl/acl.h"
#include "runtime/rt.h"
#include "acl_stub.h"

using namespace std;
using namespace testing;
using namespace acl;
using namespace acl::dvpp;

void VdecCallbackStub(acldvppStreamDesc *input, acldvppPicDesc *output, void *userData)
{

}

class VdecTest : public testing::Test {
protected:

    void SetUp()
    {
    }

    void TearDown()
    {
        Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    }
};

TEST_F(VdecTest, aclvdecCreateChannelDesc_1)
{
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    uint32_t outMode = 2;
    aclError ret = aclvdecSetChannelDescOutMode(vdecChannelDesc, outMode);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

void* mmAlignMallocStub_dvpp(mmSize mallocSize, mmSize alignSize)
{
    aclvdecChannelDesc *aclChannelDesc = nullptr;
    mallocSize = CalAclDvppStructSize(aclChannelDesc);
    return malloc(mallocSize);
}

TEST_F(VdecTest, aclvdecCreateChannel_1)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = nullptr;
    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    uint32_t outMode = 1;
    ret = aclvdecSetChannelDescOutMode(vdecChannelDesc, outMode);
    EXPECT_EQ(ret, ACL_SUCCESS);
    ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_2)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDevice(_))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_3)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDeviceCapability(_, _, _, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_4)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.aicpuVersion_ = acl::dvpp::AICPU_VERSION_NO_NOTIFY;
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_HOST;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamSynchronize(_))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_5)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCtxGetCurrent(_))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));

    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_6)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtEventCreateWithFlag(_, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));

    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_7)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamCreate(_, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));

    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_8)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamCreate(_, _))
        .WillOnce(Return((RT_ERROR_NONE)))
        .WillRepeatedly(Return(ACL_ERROR_RT_PARAM_INVALID));

    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_9)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMemcpyAsync(_, _, _, _, _, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));

    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_10)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_11)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamCreate(_, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetStreamId(_, _))
        .WillOnce(Return((RT_ERROR_NONE)))
        .WillRepeatedly(Return(ACL_ERROR_RT_PARAM_INVALID));
    ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_12)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_DEVICE;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->isNeedNotify = true;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDevice(_))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyCreate(_, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->isNeedNotify = true;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDevice(_))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyCreate(_, _))
        .WillOnce(Return(RT_ERROR_NONE))
        .WillRepeatedly(Return(ACL_ERROR_RT_PARAM_INVALID));
    ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);


    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDevice(_))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyCreate(_, _))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetNotifyID(_, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDevice(_))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyCreate(_, _))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetNotifyID(_, _))
        .WillOnce(Return(RT_ERROR_NONE))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDevice(_))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyCreate(_, _))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetNotifyID(_, _))
        .WillRepeatedly(Return(RT_ERROR_NONE));
    ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);

    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_13)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_DEVICE;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->isNeedNotify = true;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDevice(_))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyCreate(_, _))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetNotifyID(_, _))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtSubscribeReport(_,_))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));

    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecCreateChannel_14)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_DEVICE;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->isNeedNotify = true;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDevice(_))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyCreate(_, _))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetNotifyID(_, _))
        .WillRepeatedly(Return(RT_ERROR_NONE));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtSubscribeReport(_,_))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));

    aclError ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

rtError_t rtGetDeviceCapabilityInv(int32_t device, int32_t moduleType, int32_t featureType, int32_t *value)
{
    *value = 1;
    return RT_ERROR_NONE;
}

TEST_F(VdecTest, aclvdecDestroyChannel_0)
{
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_DEVICE;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = nullptr;
    aclError ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->vdecWaitTaskType = EVENT_TASK;
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecDestroyChannel_1)
{
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_DEVICE;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = nullptr;
    aclError ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamSynchronize(_))
        .WillRepeatedly(Return(ACL_ERROR_RT_PARAM_INVALID));
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _,_))
        .WillRepeatedly(Return(ACL_ERROR_RT_FEATURE_NOT_SUPPORT));
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->eosBackFlag.store(true);
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamSynchronize(_))
        .WillOnce(Return(RT_ERROR_NONE))
        .WillOnce(Return(RT_ERROR_NONE))
        .WillRepeatedly(Return(ACL_ERROR_RT_PARAM_INVALID));
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->eosBackFlag.store(true);
    vdecChannelDesc->isNeedNotify = true;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtUnSubscribeReport(_, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->eosBackFlag.store(true);
    vdecChannelDesc->isNeedNotify = false;
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecDestroyChannel_2)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->isNeedNotify = true;
    vdecChannelDesc->eosBackFlag.store(true);
    vdecChannelDesc->vdecWaitTaskType = EVENT_TASK;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamWaitEvent(_, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->isNeedNotify = true;
    vdecChannelDesc->eosBackFlag.store(true);
    vdecChannelDesc->vdecWaitTaskType = EVENT_TASK;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamWaitEvent(_, _))
        .WillOnce(Return(RT_ERROR_NONE));
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtEventReset(_, _))
        .WillRepeatedly(Return(ACL_ERROR_RT_PARAM_INVALID));
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->isNeedNotify = false;
    vdecChannelDesc->eosBackFlag.store(true);
    vdecChannelDesc->vdecWaitTaskType = EVENT_TASK;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillRepeatedly(Return(ACL_ERROR_RT_FEATURE_NOT_SUPPORT));
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_v100_1)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->callback = VdecCallbackStub;
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = true;
    vdecChannelDesc->eosBackFlag.store(true);
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_SUCCESS);

    inputStreamDesc->dvppStreamDesc.eos = true;
    vdecChannelDesc->eosBackFlag.store(true);
    ret = aclvdecSendSkippedFrame(vdecChannelDesc, inputStreamDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_v100_2)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = true;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMemcpy(_, _, _, _, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_3)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_4)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->callback = VdecCallbackStub;
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = false;
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_5)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMemcpy(_, _, _, _, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_6)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMemcpy(_, _, _, _, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_7)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_8)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyWait(_, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_9)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillOnce(Return(RT_ERROR_NONE))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_10)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyWait(_, _))
        .WillOnce(Return((RT_ERROR_NONE)))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_11)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamSynchronize(_))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_12)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = false;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCallbackLaunch(_, _, _, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V100_13)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    inputStreamDesc->dvppStreamDesc.eos = true;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamSynchronize(_))
        .WillRepeatedly(Return((ACL_ERROR_RT_PARAM_INVALID)));
    vdecChannelDesc->eosBackFlag.store(true);
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_v100_14)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aicpuVersion_ = 3;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetDeviceCapability(_,_,_,_))
        .WillRepeatedly(Invoke((rtGetDeviceCapabilityInv)));
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->isNeedNotify = false;
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = true;
    vdecChannelDesc->eosBackFlag.store(true);
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_v200_1)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);

    ret = aclvdecCreateChannel(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);

    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);

    ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);

    aclvdecDestroyChannel(vdecChannelDesc);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_2)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = true;
    vdecChannelDesc->eosBackFlag.store(true);
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMemcpy(_, _, _, _, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_3)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = true;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_4)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    vdecChannelDesc->callback = VdecCallbackStub;
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_5)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMemcpy(_, _, _, _, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_6)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMemcpy(_, _, _, _, _))
        .WillOnce(Return((RT_ERROR_NONE)))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_7)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_8)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyWait(_, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_9)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillOnce(Return(RT_ERROR_NONE))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_10)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyWait(_, _))
        .WillOnce(Return((RT_ERROR_NONE)))
        .WillRepeatedly(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_11)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = malloc(4);
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamSynchronize(_))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    free(dataDev);
    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_12)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCallbackLaunch(_, _, _, _))
        .WillOnce(Return((ACL_ERROR_RT_PARAM_INVALID)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_NE(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame_V200_13)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    inputStreamDesc->dvppStreamDesc.eos = true;
    vdecChannelDesc->eosBackFlag.store(true);

    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_SUCCESS);

    free(vdecChannelDesc->sendFrameStream);
    free(vdecChannelDesc->getFrameStream);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

rtError_t rtCallbackLaunchStubCallBackError(rtCallback_t callBackFunc, void *fnData, rtStream_t stream, bool isBlock)
{
    callBackFunc(nullptr);
    return RT_ERROR_NONE;
}

rtError_t rtCallbackLaunchStubCallBackOk(rtCallback_t callBackFunc, void *fnData, rtStream_t stream, bool isBlock)
{
    callBackFunc(fnData);
    return RT_ERROR_NONE;
}

TEST_F(VdecTest, aclvdecSendFrame_v100_callback_error)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = (rtStream_t)4;
    vdecChannelDesc->getFrameStream = (rtStream_t)4;
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = (void*)4;
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);

    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCallbackLaunch(_, _, _, _))
        .WillRepeatedly(Invoke((rtCallbackLaunchStubCallBackError)));
    aclError ret = aclvdecSendFrame(vdecChannelDesc, inputStreamDesc, outputPicDesc, nullptr, nullptr);
    EXPECT_EQ(ret, ACL_SUCCESS);

    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, GetFrameCallback_v100)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    uint64_t frameId = 1;
    memcpy(vdecChannelDesc->shareBuffer.data, &frameId, 8);
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = (rtStream_t)4;
    vdecChannelDesc->getFrameStream = (rtStream_t)4;
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    void *dataDev = (void*)4;
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();
    acldvppSetPicDescData(outputPicDesc, dataDev);
    acldvppSetPicDescSize(outputPicDesc, 4);
    inputStreamDesc->dvppStreamDesc.eos = false;
    vdecChannelDesc->eosBackFlag.store(true);

    aicpu::dvpp::VdecCallbackInfoPtr callbackInfoPtr = nullptr;
    callbackInfoPtr = std::make_shared<aicpu::dvpp::VdecGetFrameCallbackInfo>(
        inputStreamDesc, outputPicDesc, nullptr, false);
    vdecChannelDesc->taskQueue.push(callbackInfoPtr);
    vdecChannelDesc->callbackMap[1] = callbackInfoPtr;

    VideoProcessor::GetVdecFrameCallback(static_cast<void *>(vdecChannelDesc));
    EXPECT_EQ(vdecChannelDesc->callbackMap.size(), 0);

    aclvdecDestroyChannelDesc(vdecChannelDesc);
    vdecChannelDesc = nullptr;

    acldvppDestroyStreamDesc(inputStreamDesc);
    inputStreamDesc = nullptr;

    acldvppDestroyPicDesc(outputPicDesc);
    outputPicDesc = nullptr;
}

TEST_F(VdecTest, aclvdecSendFrame)
{
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    acldvppStreamDesc *input;
    acldvppPicDesc *output;
    aclvdecFrameConfig *config;
    void *userData;

    aclError ret = aclvdecSendFrame(channelDesc, input, output, config, userData);
    EXPECT_NE(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, aclvdecSendSkippedFrame)
{
    aclvdecChannelDesc *channelDesc = nullptr;
    acldvppStreamDesc *input;
    aclvdecFrameConfig *config;
    void *userData;

    aclError ret = aclvdecSendSkippedFrame(channelDesc, input, config, userData);
    EXPECT_NE(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, acldvppVpcEqualizeHistAsyncTest)
{
    acldvppChannelDesc channelDesc;
    channelDesc.dataBuffer.data = (void*)0x1;
    channelDesc.notify = (void*)0x1;
    channelDesc.isNeedNotify = false;

    acldvppPicDesc inputDesc;
    inputDesc.dataBuffer.data = (void*)0x1;
    inputDesc.dataBuffer.length = sizeof(aicpu::dvpp::DvppPicDesc);
    acldvppPicDesc outputDesc;
    outputDesc.dataBuffer.data = (void*)0x1;
    outputDesc.dataBuffer.length = sizeof(aicpu::dvpp::DvppPicDesc);

    acldvppLutMap lutMap;
    uint8_t *tempPtr = new uint8_t[3];
    lutMap.dvppLutMap.map = tempPtr;
    lutMap.dvppLutMap.lens[0] = 1;
    lutMap.dvppLutMap.lens[1] = 1;
    lutMap.dvppLutMap.lens[2] = 1;

    aclrtStream stream;
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();

    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    imageProcessor->acldvppVpcEqualizeHistAsync(&channelDesc, &inputDesc, &outputDesc, &lutMap, stream);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    delete[] tempPtr;
}

TEST_F(VdecTest, acldvppVpcBatchCropResizeMakeBorderAsyncTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    acldvppChannelDesc channelDesc;
    acldvppResizeConfig resizeConfig;

    acldvppBatchPicDesc *inputBatch = acldvppCreateBatchPicDesc(1);
    acldvppBatchPicDesc *outputBatch = acldvppCreateBatchPicDesc(1);

    acldvppPicDesc *inputDesc = acldvppGetPicDesc(inputBatch, 0);
    acldvppPicDesc *outputDesc = acldvppGetPicDesc(outputBatch, 0);
    acldvppRoiConfig  *roiConfig =  acldvppCreateRoiConfig(1, 1, 1, 1);
    acldvppRoiConfig  *pasteRoiConfig =  acldvppCreateRoiConfig(1, 1, 1, 1);
    inputBatch->dvppBatchPicDescs.batchSize = 1;
    aclrtStream stream;
    channelDesc.dataBuffer.data = (void*)0x1;
    channelDesc.dataBuffer.length = sizeof(uint64_t);
    inputDesc->dataBuffer.data = (void*)0x1;
    inputDesc->dataBuffer.length = sizeof(aicpu::dvpp::DvppPicDesc);
    outputDesc->dataBuffer.data = (void*)0x1;
    outputDesc->dataBuffer.length = sizeof(aicpu::dvpp::DvppPicDesc);
    inputDesc->dvppPicDesc.format = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
    outputDesc->dvppPicDesc.format = PIXEL_FORMAT_YVU_SEMIPLANAR_420;

    uint32_t *roiNums = new uint32_t[1];
    roiNums[0] = 1;
    channelDesc.notify = (void*)0x1;

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();
    acldvppBorderConfig *borderConfig = dvppManager.GetImageProcessor()->acldvppCreateBorderConfig();
    EXPECT_NE(acldvppVpcBatchCropResizeMakeBorderAsync(&channelDesc, inputBatch, roiNums, 2, outputBatch,
                                    &roiConfig, &borderConfig, &resizeConfig, stream), ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    inputBatch->dvppBatchPicDescs.batchSize = 2;
    EXPECT_NE(acldvppVpcBatchCropResizeMakeBorderAsync(&channelDesc, inputBatch, roiNums, 2, outputBatch,
                                    &roiConfig, &borderConfig, &resizeConfig, stream), ACL_SUCCESS);
    acldvppDestroyBorderConfig(borderConfig);
    acldvppDestroyRoiConfig(roiConfig);
    acldvppDestroyRoiConfig(pasteRoiConfig);
    acldvppDestroyBatchPicDesc(inputBatch);
    acldvppDestroyBatchPicDesc(outputBatch);
    delete[] roiNums;
}

TEST_F(VdecTest, CreateEventForVdecChannelTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc vencChannelDesc;
    vencChannelDesc.dataBuffer.data = reinterpret_cast<void *>(0x1);
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtEventCreateWithFlag(_, _))
        .WillOnce(Return((1)));
    imageProcessor->CreateEventForVdecChannel(&vencChannelDesc);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtEventCreateWithFlag(_, _))
        .WillOnce(Return((0)))
        .WillOnce(Return((1)));
    imageProcessor->CreateEventForVdecChannel(&vencChannelDesc);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtEventCreateWithFlag(_, _))
        .WillOnce(Return((0)))
        .WillOnce(Return((0)));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetEventID(_, _))
        .WillOnce(Return((1)));
    imageProcessor->CreateEventForVdecChannel(&vencChannelDesc);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtEventCreateWithFlag(_, _))
        .WillOnce(Return((0)))
        .WillOnce(Return((0)));

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetEventID(_, _))
        .WillOnce(Return((0)))
        .WillOnce(Return(1));
    imageProcessor->CreateEventForVdecChannel(&vencChannelDesc);
}

TEST_F(VdecTest, DestroyAllNotifyAndStreamForVdecChannelTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vencChannelDesc = nullptr;
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    bool isNeedNotify;

    imageProcessor->DestroyAllNotifyAndStreamForVdecChannel(vencChannelDesc, isNeedNotify);

    vencChannelDesc = aclvdecCreateChannelDesc();
    vencChannelDesc->sendFrameStream = (rtStream_t)0x11;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamDestroy(_))
        .WillOnce(Return((1)));
    imageProcessor->DestroyAllNotifyAndStreamForVdecChannel(vencChannelDesc, isNeedNotify);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    vencChannelDesc->getFrameStream = (rtStream_t)0x11;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamDestroy(_))
        .WillOnce(Return((1)));
    imageProcessor->DestroyAllNotifyAndStreamForVdecChannel(vencChannelDesc, isNeedNotify);
    aclvdecDestroyChannelDesc(vencChannelDesc);
}

TEST_F(VdecTest, DestroyAllEventForVdecChannelTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vencChannelDesc = aclvdecCreateChannelDesc();
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    vencChannelDesc->sendFrameNotify = (void *)0x11;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtEventDestroy(_))
        .WillOnce(Return((1)));
    imageProcessor->DestroyAllEventForVdecChannel(vencChannelDesc);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));

    vencChannelDesc->getFrameNotify = (void *)0x11;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtEventDestroy(_))
        .WillOnce(Return((1)));
    imageProcessor->DestroyAllEventForVdecChannel(vencChannelDesc);
    aclvdecDestroyChannelDesc(vencChannelDesc);
}

TEST_F(VdecTest, DestroyAllNotifyForVdecChannelTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStub_dvpp));
    aclvdecChannelDesc *vencChannelDesc = aclvdecCreateChannelDesc();
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    vencChannelDesc->sendFrameNotify = (void *)0x11;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyDestroy(_))
        .WillOnce(Return((1)));
    imageProcessor->DestroyAllNotifyForVdecChannel(vencChannelDesc);

    vencChannelDesc->getFrameNotify = (void *)0x11;
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtNotifyDestroy(_))
        .WillOnce(Return((1)));
    imageProcessor->DestroyAllNotifyForVdecChannel(vencChannelDesc);
    aclvdecDestroyChannelDesc(vencChannelDesc);
}

TEST_F(VdecTest, LaunchTaskForGetStreamTest)
{
    aclvdecChannelDesc vdecChannelDesc;
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    vdecChannelDesc.isNeedNotify = false;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    imageProcessor->LaunchTaskForGetStream(&vdecChannelDesc);
}

TEST_F(VdecTest, CreateVdecChannelDescOnDeviceTest)
{
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMalloc(_, _, _))
        .WillOnce(Return((1)));
    imageProcessor->CreateVdecChannelDescOnDevice();
}

TEST_F(VdecTest, CreateVdecChannelDescOnHostTest)
{
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillOnce(Return((VOID *)nullptr));
    imageProcessor->CreateVdecChannelDescOnHost();
}

TEST_F(VdecTest, CreateDvppStreamDescOnDeviceTest)
{
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMalloc(_, _, _))
        .WillOnce(Return((1)));
    imageProcessor->CreateDvppStreamDescOnDevice();
}

TEST_F(VdecTest, CreateDvppStreamDescOnHostTest)
{
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillOnce(Return((VOID *)nullptr));
    imageProcessor->CreateDvppStreamDescOnHost();
}

TEST_F(VdecTest, v100_aclvdecSetChannelDescChannelIdTest)
{
    aclvdecChannelDesc *channelDesc = nullptr;
    uint32_t channelId;
    acl::dvpp::VideoProcessorV100 v100(ACL_HOST);

    v100.aclvdecSetChannelDescChannelId(channelDesc, channelId);

    channelDesc = aclvdecCreateChannelDesc();
    channelId = 32;
    v100.aclvdecSetChannelDescChannelId(channelDesc, channelId);
    aclvdecDestroyChannelDesc(channelDesc);
}

void* mmAlignMallocDvppStub(mmSize mallocSize, mmSize alignSize)
{
    aclvdecChannelDesc *aclChannelDesc = nullptr;
    mallocSize = CalAclDvppStructSize(aclChannelDesc);
    return malloc(mallocSize);
}

TEST_F(VdecTest, v100_aclvdecSetChannelDescOutPicFormatTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *channelDesc = nullptr;
    acldvppPixelFormat outPicFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
    acl::dvpp::VideoProcessorV100 v100(ACL_HOST);
    aclError ret = v100.aclvdecSetChannelDescOutPicFormat(channelDesc, outPicFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    channelDesc = aclvdecCreateChannelDesc();
    outPicFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_422;
    ret = v100.aclvdecSetChannelDescOutPicFormat(channelDesc, outPicFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    aclvdecDestroyChannelDesc(channelDesc);
}

TEST_F(VdecTest, v100_aclvencSetChannelDescIPPropTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvencChannelDesc *channelDesc = nullptr;
    auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    uint32_t ipProp = 1;
    aclError ret = videoProcessor->aclvencSetChannelDescIPProp(channelDesc, ipProp);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    aclvencChannelDesc *vencChannelDesc = aclvencCreateChannelDesc();
    VencTLVType type = VENC_IP_PROP;
    VencChannelDescTLVParam vencChannelPram;
    vencChannelPram.valueLen = 1;
    vencChannelPram.value = nullptr;
    vencChannelDesc->tlvParamMap.insert(std::pair<VencTLVType, VencChannelDescTLVParam>(type, vencChannelPram));
    ret = videoProcessor->aclvencSetChannelDescIPProp(vencChannelDesc, ipProp);
    aclvencDestroyChannelDesc(vencChannelDesc);
}

TEST_F(VdecTest, v100_aclvencGetChannelDescIPPropTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvencChannelDesc *channelDesc = nullptr;
    auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    aclError ret = videoProcessor->aclvencGetChannelDescIPProp(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);

    aclvencChannelDesc *vencChannelDesc = aclvencCreateChannelDesc();
    VencTLVType type = VENC_IP_PROP;
    VencChannelDescTLVParam vencChannelPram;
    vencChannelPram.valueLen = 1;
    vencChannelPram.value = nullptr;
    vencChannelDesc->tlvParamMap.insert(std::pair<VencTLVType, VencChannelDescTLVParam>(type, vencChannelPram));
    ret = videoProcessor->aclvencGetChannelDescIPProp(vencChannelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    aclvencDestroyChannelDesc(channelDesc);
}

TEST_F(VdecTest, v200_aclvdecSetChannelDescMatrixTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *channelDesc = nullptr;
    acldvppCscMatrix matrixFormat = ACL_DVPP_CSC_MATRIX_BT601_WIDE;
    acl::dvpp::VideoProcessorV200 v200(ACL_HOST);

    aclError ret = v200.aclvdecSetChannelDescMatrix(channelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    matrixFormat = (acldvppCscMatrix)(6);
    ret = v200.aclvdecSetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    matrixFormat = ACL_DVPP_CSC_MATRIX_BT601_NARROW;
    VdecTLVType type = VDEC_BIT_DEPTH;
    VdecChannelDescTLVParam vdecChannelPram;
    vdecChannelPram.valueLen = 1;
    vdecChannelPram.value = nullptr;
    vdecChannelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram));
    ret = v200.aclvdecSetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_SUCCESS);

    type = VDEC_CSC_MATRIX;
    vdecChannelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram));
    ret = v200.aclvdecSetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
}

TEST_F(VdecTest, v200_aclvdecGetChannelDescMatrixTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *channelDesc = nullptr;
    acldvppCscMatrix matrixFormat = ACL_DVPP_CSC_MATRIX_BT601_WIDE;
    acl::dvpp::VideoProcessorV200 v200(ACL_HOST);
    aclError ret = v200.aclvdecGetChannelDescMatrix(channelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    VdecTLVType type = VDEC_BIT_DEPTH;
    VdecChannelDescTLVParam vdecChannelPram;
    vdecChannelPram.valueLen = 1;
    vdecChannelPram.value = nullptr;
    vdecChannelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram));
    ret = v200.aclvdecGetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_SUCCESS);

    type = VDEC_CSC_MATRIX;
    vdecChannelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram));
    v200.aclvdecSetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    ret = v200.aclvdecGetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    type = VDEC_BIT_DEPTH;
    vdecChannelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram));
    v200.aclvdecSetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    ret = v200.aclvdecGetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    vdecChannelDesc->tlvParamMap.clear();

    type = VDEC_CSC_MATRIX;
    matrixFormat = ACL_DVPP_CSC_MATRIX_BT601_WIDE;
    vdecChannelPram.valueLen = 1;
    vdecChannelPram.value = std::shared_ptr<int>(new int(100));
    vdecChannelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram));
    ret = v200.aclvdecGetChannelDescMatrix(vdecChannelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_SUCCESS);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
}

TEST_F(VdecTest, VideoProcessorV200_aclvdecGetChannelDescBitDepthTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    VdecTLVType type = VDEC_BIT_DEPTH;
    VdecChannelDescTLVParam vdecChannelPram;
    vdecChannelPram.valueLen = 1;
    vdecChannelPram.value = nullptr;
    vdecChannelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram));
    acl::dvpp::VideoProcessorV200 v200(ACL_HOST);
    uint32_t ret = v200.aclvdecGetChannelDescBitDepth(vdecChannelDesc);
    EXPECT_EQ(ret, 0);

    type = VDEC_CSC_MATRIX;
    uint32_t bitDepth = 1;
    vdecChannelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram));
    v200.aclvdecSetChannelDescBitDepth(vdecChannelDesc, bitDepth);
    ret = v200.aclvdecGetChannelDescBitDepth(vdecChannelDesc);
    EXPECT_EQ(ret, 0);
    aclvdecDestroyChannelDesc(vdecChannelDesc);
}

TEST_F(VdecTest, VideoProcessor_unknownRunModeTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    // unknown acl run mode
    aclrtRunMode runMode = (aclrtRunMode)(3);
    acl::dvpp::VideoProcessorV200 V200(runMode);
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    EXPECT_EQ(vdecChannelDesc, nullptr);

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_DEVICE;
    dvppManager.InitDvppProcessor();
    vdecChannelDesc = aclvdecCreateChannelDesc();

    runMode = (aclrtRunMode)(4);
    acl::dvpp::VideoProcessorV200 v200(runMode);
    aclError ret = aclvdecDestroyChannelDesc(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_ERROR_INTERNAL_ERROR);
}

TEST_F(VdecTest, acldvppCreateStreamDesc_unknownRunModeTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclrtRunMode runMode = (aclrtRunMode)(3);
    acl::dvpp::VideoProcessorV200 V200(runMode);
    acldvppStreamDesc *streamDesc = acldvppCreateStreamDesc();
    EXPECT_EQ(streamDesc, nullptr);

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_DEVICE;
    dvppManager.InitDvppProcessor();
    streamDesc = acldvppCreateStreamDesc();

    runMode = (aclrtRunMode)(4);
    acl::dvpp::VideoProcessorV200 v200(runMode);
    aclError ret = acldvppDestroyStreamDesc(streamDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, aclvdecCreateFrameConfigTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V100;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();

    aclvdecFrameConfig *config = aclvdecCreateFrameConfig();
    EXPECT_NE(config, nullptr);
    aclError ret = aclvdecDestroyFrameConfig(config);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, SetVdecParamToVdecChannelTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    VdecTLVType type = VDEC_CSC_MATRIX;
    VdecChannelDescTLVParam vdecChannelPram1;
    vdecChannelPram1.valueLen = 10000;
    vdecChannelPram1.value = std::shared_ptr<int>(new int(100));
    channelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram1));
    aclError ret = videoProcessor->SetVdecParamToVdecChannel(channelDesc);
    EXPECT_EQ(ret, ACL_ERROR_FAILURE);

    channelDesc->tlvParamMap.clear();
    type = VDEC_CSC_MATRIX;
    VdecChannelDescTLVParam vdecChannelPram2;
    vdecChannelPram2.valueLen =10;
    vdecChannelPram2.value = std::shared_ptr<int>(new int(1));
    channelDesc->tlvParamMap.insert(std::pair<VdecTLVType, VdecChannelDescTLVParam>(type, vdecChannelPram2));
    ret = videoProcessor->SetVdecParamToVdecChannel(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    ret = aclvdecDestroyChannelDesc(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, aclvdecSetChannelDescMatrixUnsupportedTest)
{
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    acldvppCscMatrix matrixFormat = ACL_DVPP_CSC_MATRIX_BT601_WIDE;
    auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    aclError ret = videoProcessor->aclvdecSetChannelDescMatrix(channelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);

    ret = videoProcessor->aclvdecGetChannelDescMatrix(channelDesc, matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);

    ret = aclvdecDestroyChannelDesc(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, GetVdecCallInfoTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    acldvppStreamDesc *input = acldvppCreateStreamDesc();
    acldvppPicDesc *output = acldvppCreatePicDesc();
    int temp = 1;
    void *userData = static_cast<void *>(&temp);
    bool eos = true;

    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMemcpy(_, _, _, _, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));

    auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    aclError ret = videoProcessor->GetVdecCallInfo(channelDesc, input, output, userData, eos);
    EXPECT_EQ(ret, ACL_ERROR_RT_PARAM_INVALID);

    acldvppDestroyStreamDesc(input);
    acldvppDestroyPicDesc(output);
    ret = aclvdecDestroyChannelDesc(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, acldvppVpcBatchCropResizeMakeBorderAsyncUnsupportedTest)
{
    auto imageProcessor = acl::dvpp::DvppManager::GetInstance().GetImageProcessor();
    acldvppChannelDesc channelDesc;
    acldvppBatchPicDesc *inputBatch = acldvppCreateBatchPicDesc(1);
    uint32_t *roiNums = new uint32_t[1];
    roiNums[0] = 1;
    acldvppResizeConfig resizeConfig;
    acldvppBatchPicDesc *outputBatch = acldvppCreateBatchPicDesc(1);
    acldvppRoiConfig  *roiConfig =  acldvppCreateRoiConfig(1, 1, 1, 1);
    aclrtStream stream;
    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    acldvppBorderConfig *borderConfig = dvppManager.GetImageProcessor()->acldvppCreateBorderConfig();

    aclError ret = imageProcessor->acldvppVpcBatchCropResizeMakeBorderAsync(&channelDesc, inputBatch, roiNums, 2, outputBatch,
                                    &roiConfig, &borderConfig, &resizeConfig, stream);

    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);

    acldvppDestroyBorderConfig(borderConfig);
    acldvppDestroyRoiConfig(roiConfig);
    acldvppDestroyBatchPicDesc(inputBatch);
    acldvppDestroyBatchPicDesc(outputBatch);
    delete[] roiNums;
}

TEST_F(VdecTest, GetVdecFrameCallbackTest)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    void *callbackData = nullptr;
    auto videoProcessor = acl::dvpp::DvppManager::GetInstance().GetVideoProcessor();
    videoProcessor->GetVdecFrameCallback(callbackData);
}

TEST_F(VdecTest, isVdecChannelAvailableTest_01)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    channelDesc->callback = VdecCallbackStub;
    aclError ret = aclvdecCreateChannel(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);

    channelDesc->callback = VdecCallbackStub;
    channelDesc->sendFrameStream = malloc(4);
    channelDesc->getFrameStream = malloc(4);
    channelDesc->eosBackFlag.store(true);
    channelDesc->isNeedNotify = false;
    ret = aclvdecDestroyChannel(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    free(channelDesc->sendFrameStream);
    free(channelDesc->getFrameStream);
    ret = aclvdecDestroyChannelDesc(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, isVdecChannelAvailableTest_02)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    channelDesc->callback = VdecCallbackStub;
    aclError ret = aclvdecCreateChannel(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    ret = aclvdecDestroyChannelDesc(channelDesc);
    EXPECT_EQ(ret, ACL_ERROR_RELATIVE_RESOURCE_NOT_CLEARED);

    channelDesc->callback = VdecCallbackStub;
    channelDesc->sendFrameStream = malloc(4);
    channelDesc->getFrameStream = malloc(4);
    channelDesc->eosBackFlag.store(true);
    channelDesc->isNeedNotify = false;
    ret = aclvdecDestroyChannel(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
    free(channelDesc->sendFrameStream);
    free(channelDesc->getFrameStream);
    ret = aclvdecDestroyChannelDesc(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, isVdecChannelAvailableTest_03)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocDvppStub));
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    channelDesc->callback = VdecCallbackStub;
    aclError ret = aclvdecDestroyChannelDesc(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

static void* mmAlignMallocStubDvpp(mmSize mallocSize, mmSize alignSize)
{
    aclvdecChannelDesc *aclChannelDesc = nullptr;
    mallocSize = CalAclDvppStructSize(aclChannelDesc);
    return malloc(mallocSize);
}

TEST_F(VdecTest, aclvdecSetGetVdecParam)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStubDvpp));
    aclvdecChannelDesc *desc = aclvdecCreateChannelDesc();
    desc->dataBuffer.data = reinterpret_cast<void *>(0x1);

    acldvppCscMatrix matrixFormat = ACL_DVPP_CSC_MATRIX_BT601_NARROW;
    auto ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_CSC_MATRIX_UINT32, 4, &matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);
    acldvppCscMatrix matrixFormat1 = ACL_DVPP_CSC_MATRIX_BT601_WIDE;
    size_t matrixFormatLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_CSC_MATRIX_UINT32, 4, &matrixFormatLen, &matrixFormat1);
    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);
    EXPECT_EQ(matrixFormat1, ACL_DVPP_CSC_MATRIX_BT601_WIDE);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_CSC_MATRIX_UINT32, 5, &matrixFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_CSC_MATRIX_UINT32, 3, &matrixFormatLen, &matrixFormat1);
    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);

    uint32_t outMode = 1;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_OUT_MODE_UINT32, 4, &outMode);
    EXPECT_EQ(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    uint32_t outMode1 = 0;
    size_t outModeLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_OUT_MODE_UINT32, 4, &outModeLen, &outMode1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(outMode1, 1);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_OUT_MODE_UINT32, 5, &outMode);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_OUT_MODE_UINT32, 3, &outModeLen, &outMode1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    uint64_t threadId = 100;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_THREAD_ID_UINT64, 8, &threadId);
    EXPECT_EQ(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    uint64_t threadId1 = 0;
    size_t threadIdLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_THREAD_ID_UINT64, 8, &threadIdLen, &threadId1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(threadId1, 100);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_THREAD_ID_UINT64, 9, &threadId);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_THREAD_ID_UINT64, 7, &threadIdLen, &threadId1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    aclvdecCallback callback = (aclvdecCallback)0x1;
    void *func = (void *)callback;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_CALLBACK_PTR, 8, &func);
    EXPECT_EQ(ret, ACL_SUCCESS);
    void *func1 = nullptr;
    size_t funcLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_CALLBACK_PTR, 8, &funcLen, &func1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(func1, (void *)0x1);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_CALLBACK_PTR, 9, &func);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_CALLBACK_PTR, 7, &funcLen, &func1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    uint32_t channelId = 1;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_CHANNEL_ID_UINT32, 4, &channelId);
    EXPECT_EQ(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    uint32_t channelId1 = 0;
    size_t channelIdLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_CHANNEL_ID_UINT32, 4, &channelIdLen, &channelId1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(channelId1, 1);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_CHANNEL_ID_UINT32, 5, &channelId);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_CHANNEL_ID_UINT32, 3, &channelIdLen, &channelId1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    acldvppStreamFormat enType = H265_MAIN_LEVEL;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_ENCODE_TYPE_UINT32, 4, &enType);
    EXPECT_EQ(ret, ACL_SUCCESS);
    acldvppStreamFormat enType1 = H264_MAIN_LEVEL;
    size_t enTypeLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_ENCODE_TYPE_UINT32, 4, &enTypeLen, &enType1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(enType1, H265_MAIN_LEVEL);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_ENCODE_TYPE_UINT32, 5, &enType);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_ENCODE_TYPE_UINT32, 3, &enTypeLen, &enType1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    acldvppPixelFormat picFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_OUT_PIC_FORMAT_UINT32, 4, &picFormat);
    EXPECT_EQ(ret, ACL_SUCCESS);
    acldvppPixelFormat picFormat1 = PIXEL_FORMAT_YUV_400;
    size_t picFormatLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_OUT_PIC_FORMAT_UINT32, 4, &picFormatLen, &picFormat1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(picFormat1, PIXEL_FORMAT_YUV_SEMIPLANAR_420);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_OUT_PIC_FORMAT_UINT32, 5, &picFormat);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_OUT_PIC_FORMAT_UINT32, 3, &picFormatLen, &picFormat1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    uint32_t picWidth = 600;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_OUT_PIC_WIDTH_UINT32, 4, &picWidth);
    EXPECT_EQ(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    uint32_t picWidth1 = 0;
    size_t picWidthLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_OUT_PIC_WIDTH_UINT32, 4, &picWidthLen, &picWidth1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(picWidth1, 600);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_OUT_PIC_WIDTH_UINT32, 5, &picWidth);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_OUT_PIC_WIDTH_UINT32, 3, &picWidthLen, &picWidth1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    uint32_t picHeight = 800;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_OUT_PIC_HEIGHT_UINT32, 4, &picHeight);
    EXPECT_EQ(ret, ACL_SUCCESS);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    uint32_t picHeight1 = 0;
    size_t picHeightLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_OUT_PIC_HEIGHT_UINT32, 4, &picHeightLen, &picHeight1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(picHeight1, 800);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_OUT_PIC_HEIGHT_UINT32, 5, &picHeight);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_OUT_PIC_HEIGHT_UINT32, 3, &picHeightLen, &picHeight1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    uint32_t refFrameNum = 60;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_REF_FRAME_NUM_UINT32, 4, &refFrameNum);
    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    uint32_t refFrameNum1 = 0;
    size_t refFrameNumLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_REF_FRAME_NUM_UINT32, 4, &refFrameNumLen, &refFrameNum1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(refFrameNum1, 0);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_REF_FRAME_NUM_UINT32, 5, &refFrameNum);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_REF_FRAME_NUM_UINT32, 3, &refFrameNumLen, &refFrameNum1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    uint32_t bitDepth = 8;
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_BIT_DEPTH_UINT32, 4, &bitDepth);
    EXPECT_EQ(ret, ACL_ERROR_FEATURE_UNSUPPORTED);
    Mock::VerifyAndClear((void *)(&MockFunctionTest::aclStubInstance()));
    uint32_t bitDepth1 = 0;
    size_t bitDepthLen = 0;
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_BIT_DEPTH_UINT32, 4, &bitDepthLen, &bitDepth1);
    EXPECT_EQ(ret, ACL_SUCCESS);
    EXPECT_EQ(bitDepth1, 0);
    ret = aclvdecSetChannelDescParam(desc, ACL_VDEC_BIT_DEPTH_UINT32, 5, &bitDepth);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);
    ret = aclvdecGetChannelDescParam(desc, ACL_VDEC_BIT_DEPTH_UINT32, 3, &bitDepthLen, &bitDepth1);
    EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM);

    aclvdecDestroyChannelDesc(desc);
}

TEST_F(VdecTest, ResetVdecChannelFailed)
{
    // execute WaitEosIsTimeout is failed
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStubDvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aicpuVersion_ = 1;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    channelDesc->needResetChannelFlag.store(true);

    aclError ret = aclvdecDestroyChannel(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, sendFrameWaitTimeout)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStubDvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aicpuVersion_ = 1;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    channelDesc->needResetChannelFlag.store(true);
    channelDesc->callback = VdecCallbackStub;
    int temp = 1;
    channelDesc->dataBuffer.data = static_cast<void *>(&temp);
    channelDesc->sendFrameStream = static_cast<void *>(&temp);
    channelDesc->getFrameStream = static_cast<void *>(&temp);
    uint32_t timeout = VideoProcessorV200::waitEosTimeout_;
    VideoProcessorV200::waitEosTimeout_ = 1;
    aclError ret = aclvdecDestroyChannel(channelDesc);
    VideoProcessorV200::waitEosTimeout_ = timeout;
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, sendFrameWaitTimeout_rtCpuKernelLaunchFailed)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStubDvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aicpuVersion_ = 1;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    channelDesc->needResetChannelFlag.store(true);
    channelDesc->callback = VdecCallbackStub;
    int temp = 1;
    channelDesc->dataBuffer.data = static_cast<void *>(&temp);
    channelDesc->sendFrameStream = static_cast<void *>(&temp);
    channelDesc->getFrameStream = static_cast<void *>(&temp);
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtCpuKernelLaunch(_, _, _, _, _, _, _))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID));
    aclError ret = aclvdecDestroyChannel(channelDesc);
    EXPECT_EQ(ret, ACL_ERROR_RT_PARAM_INVALID);
}

TEST_F(VdecTest, aclvdecSendFrame_aicpuTimeout)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStubDvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aicpuVersion_ = 1;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();
    aclvdecChannelDesc *channelDesc = aclvdecCreateChannelDesc();
    channelDesc->needResetChannelFlag.store(true);
    channelDesc->callback = VdecCallbackStub;

    int temp = 1;
    channelDesc->dataBuffer.data = static_cast<void *>(&temp);
    channelDesc->sendFrameStream = static_cast<void *>(&temp);
    channelDesc->getFrameStream = static_cast<void *>(&temp);
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtStreamSynchronize(_))
        .WillOnce(Return(ACL_ERROR_RT_PARAM_INVALID))
        .WillRepeatedly(Return(ACL_SUCCESS));
    aclError ret = aclvdecDestroyChannel(channelDesc);
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, aclvdecSendFrame_abnormalChannel)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStubDvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aicpuVersion_ = 1;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    uint64_t frameId = 1;
    memcpy(vdecChannelDesc->shareBuffer.data, &frameId, 8);
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    inputStreamDesc->dvppStreamDesc.eos = true;
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    aicpu::dvpp::VdecCallbackInfoPtr callbackInfoPtr = nullptr;
    callbackInfoPtr = std::make_shared<aicpu::dvpp::VdecGetFrameCallbackInfo>(
        inputStreamDesc, outputPicDesc, nullptr, true);
    vdecChannelDesc->taskQueue.push(callbackInfoPtr);
    vdecChannelDesc->callbackMap[1] = callbackInfoPtr;

    VdecCallbackResultInfo info;
    info.errCode = 16;
    info.frameId = 0;
    vdecChannelDesc->callbackMap[0] = callbackInfoPtr;
    vdecChannelDesc->shareBuffer.data = &info;
    bool eos = true;
    void *userData = nullptr;
    aclError ret = VideoProcessor::GetVdecCallInfo(vdecChannelDesc, inputStreamDesc, outputPicDesc, userData, eos);
    EXPECT_EQ(ret, ACL_SUCCESS);

    vdecChannelDesc->needResetChannelFlag.store(true);
    uint32_t timeout = VideoProcessorV200::waitEosTimeout_;
    VideoProcessorV200::waitEosTimeout_ = 1;
    ret = aclvdecDestroyChannel(vdecChannelDesc);
    VideoProcessorV200::waitEosTimeout_ = timeout;
    EXPECT_EQ(ret, ACL_SUCCESS);
}

TEST_F(VdecTest, aclvdecSendFrame_abnormalEos)
{
    EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmAlignMalloc(_, _))
        .WillRepeatedly(Invoke(mmAlignMallocStubDvpp));

    acl::dvpp::DvppManager &dvppManager = acl::dvpp::DvppManager::GetInstance();
    dvppManager.version_ = DVPP_KERNELS_V200;
    dvppManager.aicpuVersion_ = 1;
    dvppManager.aclRunMode_ = ACL_HOST;
    dvppManager.InitDvppProcessor();
    aclvdecChannelDesc *vdecChannelDesc = aclvdecCreateChannelDesc();
    uint64_t frameId = 1;
    memcpy(vdecChannelDesc->shareBuffer.data, &frameId, 8);
    vdecChannelDesc->callback = VdecCallbackStub;
    vdecChannelDesc->sendFrameStream = malloc(4);
    vdecChannelDesc->getFrameStream = malloc(4);
    acldvppStreamDesc *inputStreamDesc = acldvppCreateStreamDesc();
    inputStreamDesc->dvppStreamDesc.eos = true;
    acldvppPicDesc *outputPicDesc = acldvppCreatePicDesc();

    aicpu::dvpp::VdecCallbackInfoPtr callbackInfoPtr = nullptr;
    callbackInfoPtr = std::make_shared<aicpu::dvpp::VdecGetFrameCallbackInfo>(
        inputStreamDesc, outputPicDesc, nullptr, true);
    vdecChannelDesc->taskQueue.push(callbackInfoPtr);
    vdecChannelDesc->callbackMap[1] = callbackInfoPtr;

    VdecCallbackResultInfo info;
    info.errCode = 16;
    info.frameId = 0;
    vdecChannelDesc->callbackMap[0] = callbackInfoPtr;
    vdecChannelDesc->shareBuffer.data = &info;
    bool eos = true;
    void *userData = nullptr;
    aclError ret = VideoProcessor::GetVdecCallInfo(vdecChannelDesc, inputStreamDesc, outputPicDesc, userData, eos);
    EXPECT_EQ(ret, ACL_SUCCESS);

    vdecChannelDesc->abnormalChannelEosFlag.store(true);
    vdecChannelDesc->eosBackFlag.store(true);
    acl::dvpp::VideoProcessorV200 videoProcessorV200(ACL_HOST);
    ret = videoProcessorV200.SendEosForVdec(vdecChannelDesc);
    EXPECT_EQ(ret, ACL_ERROR_RT_AICPU_EXCEPTION);
}